//
//  ScCell.swift
//  Auscultation
//
//  Created by 来 on 2020/12/22.
//

import UIKit

protocol ScCellDelegate: class {
    func selectFX(_ cell: ScCell,_ index: Int)
}
class ScCell: UICollectionViewCell {
    
    weak var delegate: ScCellDelegate?
    
    var tzzx: UILabel!
    var cjsj: UILabel!
    var xm: UILabel!
    var nl: UILabel!
    var tw: UILabel!
    var phcd: UILabel!
    
    var zt: UILabel!
    var fx: UILabel!
    var fx_i: UIImageView!
    var fx_s: UILabel!
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        let back = UIView.init()
        back.backgroundColor = UIColor.white
        back.clipsToBounds = true
        back.layer.cornerRadius = 4
        addSubview(back)
        back.snp.makeConstraints { (make) in
            make.edges.equalTo(UIEdgeInsets.init(top: 10, left: 16, bottom: 10, right: 16))
        }
        
        tzzx = UILabel.init()
        tzzx.lgf_AddShowAllText()
        tzzx.font = UIFont.boldSystemFont(ofSize: 16)
        tzzx.textColor = UIColor.init(lgf_HexString: "222222")
        tzzx.text = "听诊中心"
        back.addSubview(tzzx)
        tzzx.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(15)
            make.left.equalToSuperview().offset(15)
            make.width.equalToSuperview().multipliedBy(0.7)
        }
        
        zt = UILabel.init()
        zt.lgf_AddShowAllText()
        zt.font = UIFont.systemFont(ofSize: 12)
        zt.textColor = UIColor.init(lgf_HexString: "0F88F2")
        zt.text = "筛查完成"
        back.addSubview(zt)
        zt.snp.makeConstraints { (make) in
            make.centerY.equalTo(tzzx)
            make.right.equalToSuperview().offset(-15)
        }
        
        cjsj = UILabel.init()
        cjsj.lgf_AddShowAllText()
        cjsj.font = UIFont.systemFont(ofSize: 12)
        cjsj.textColor = UIColor.init(lgf_HexString: "8D969D")
        cjsj.text = "创建时间："
        back.addSubview(cjsj)
        cjsj.snp.makeConstraints { (make) in
            make.top.equalTo(tzzx.snp.bottom).offset(10)
            make.left.equalTo(tzzx)
        }
        
        xm = UILabel.init()
        xm.lgf_AddShowAllText()
        xm.font = UIFont.systemFont(ofSize: 12)
        xm.textColor = UIColor.init(lgf_HexString: "8D969D")
        xm.text = "姓名："
        back.addSubview(xm)
        xm.snp.makeConstraints { (make) in
            make.top.equalTo(cjsj.snp.bottom).offset(4)
            make.left.equalTo(tzzx)
            make.width.equalToSuperview().multipliedBy(0.5).offset(-15)
        }
        
        nl = UILabel.init()
        nl.lgf_AddShowAllText()
        nl.font = UIFont.systemFont(ofSize: 12)
        nl.textColor = UIColor.init(lgf_HexString: "8D969D")
        nl.text = "年龄："
        back.addSubview(nl)
        nl.snp.makeConstraints { (make) in
            make.centerY.equalTo(xm)
            make.left.equalTo(xm.snp.right)
            make.width.equalToSuperview().multipliedBy(0.5).offset(-15)
        }
        
        tw = UILabel.init()
        tw.lgf_AddShowAllText()
        tw.font = UIFont.systemFont(ofSize: 12)
        tw.textColor = UIColor.init(lgf_HexString: "8D969D")
        tw.text = "体位："
        back.addSubview(tw)
        tw.snp.makeConstraints { (make) in
            make.top.equalTo(xm.snp.bottom).offset(4)
            make.left.equalTo(tzzx)
            make.width.equalToSuperview().multipliedBy(0.5).offset(-15)
        }
        
        phcd = UILabel.init()
        phcd.lgf_AddShowAllText()
        phcd.font = UIFont.systemFont(ofSize: 12)
        phcd.textColor = UIColor.init(lgf_HexString: "8D969D")
        phcd.text = "配合程度："
        back.addSubview(phcd)
        phcd.snp.makeConstraints { (make) in
            make.top.equalTo(xm.snp.bottom).offset(4)
            make.left.equalTo(tw.snp.right)
            make.width.equalToSuperview().multipliedBy(0.5).offset(-15)
        }
        
        let line1 = UIView.init()
        line1.backgroundColor = UIColor.init(lgf_HexString: "EAEDEF")
        back.addSubview(line1)
        line1.snp.makeConstraints { (make) in
            make.bottom.equalToSuperview().offset(-40)
            make.left.right.equalToSuperview()
            make.height.equalTo(0.5)
        }
        
        fx = UILabel.init()
        fx.font = UIFont.boldSystemFont(ofSize: 16)
        fx.textColor = UIColor.init(lgf_HexString: "F27C0F")
        fx.text = "分析中"
        fx.textAlignment = .center
        fx.lgf_AddTap(target: self, action: #selector(s_fx))
        back.addSubview(fx)
        fx.snp.makeConstraints { (make) in
            make.top.equalTo(line1.snp.bottom)
            make.bottom.equalToSuperview()
            make.centerX.equalToSuperview()
        }
        fx_i = UIImageView.init(image: #imageLiteral(resourceName: "bangdin备份"))
        back.addSubview(fx_i)
        fx_i.snp.makeConstraints { (make) in
            make.right.equalTo(fx.snp.left).offset(-7)
            make.centerY.equalTo(fx)
            make.width.height.equalTo(13)
        }
        fx_s = UILabel.init()
        fx_s.text = ""
        fx_s.textAlignment = .center
        fx_s.font = UIFont.boldSystemFont(ofSize: 11)
        fx_s.backgroundColor = UIColor.init(lgf_HexString: "FFF1E4")?.withAlphaComponent(0.1)
        fx_s.textColor = UIColor.init(lgf_HexString: "FFF1E4")
        fx_s.layer.borderColor = UIColor.init(lgf_HexString: "FFF1E4")?.withAlphaComponent(0.1).cgColor
        fx_s.layer.borderWidth = 1.0
        fx_s.layer.cornerRadius = 2.0
        back.addSubview(fx_s)
        fx_s.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(-15)
            make.centerY.equalTo(fx)
            make.height.equalTo(18)
            make.width.equalTo(54)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    @objc func s_fx() {
        self.delegate?.selectFX(self, self.tag)
    }
    
}
